package logic.courseQuery_logic;

import java.util.List;

import javaRMI.RMIClient;
import logic.utility_logic.NetConnectException;
import logicsv.courseQuery_logicsv.CourseQueryLogicsv;
import po.StuCouScoRecPO;
import resultmessage.CollegeQueryRM;
import resultmessage.CourseQueryRM;
import vo.CouStuScoListVO;
import vo.CouStuScoSecVO;
import vo.CourseVO;

public class CourseQueryLogicsvController implements CourseQueryLogicsv {
	private StuCouScoList stuCouScoList;
	private TeaCouList teaCouList ;
	private CourseList courseList ;
	private SubModelCourseList smcList;
	private RMIClient rmi;
	public CourseQueryLogicsvController(RMIClient rmi){
		this.rmi = rmi;
		stuCouScoList = new StuCouScoList(rmi);
		 teaCouList = new TeaCouList(rmi);
		courseList = new CourseList(rmi);
		smcList = new SubModelCourseList(rmi);
	}


	@Override
	public CouStuScoListVO getAllStuOfCou(String courseID){
		return courseList.getAllStuOfCou(courseID);
	}

	public List<StuCouScoRecPO> getCourses(String studentID){
		return stuCouScoList.getCourses(studentID);
	}


	@Override
	public List<CourseVO> getAllCouOfStu(String studentID) {
		return stuCouScoList.getAllCouOfStu(studentID);
	}


	@Override
	public List<CourseVO> getAllCouOfTea(String teacherID) {
		return teaCouList.getAllCouOfTea(teacherID);
	}

	@Override
	public CouStuScoSecVO getCouStuScoSec(String courseID,List<ScoreSection> sections) {
		CouStuScoSecCounter counter = new CouStuScoSecCounter(rmi,courseID,sections);
		return new CouStuScoSecVO(counter.getNumStuOfScoSec());
	}

	@Override
	public CollegeQueryRM deleteCourse(String collegeID, String courseID) {
		return courseList.deleteCourse(collegeID, courseID);
	}

	@Override
	public CollegeQueryRM addCourse(String collegeID, String courseID) {
		return courseList.addCourse(collegeID, courseID);
	}

	@Override
	public CourseQueryRM deleteStuCouRec(String courseID, String studentID) {
		return stuCouScoList.deleteStuOfCou(courseID, studentID);
	}

	@Override
	public CourseQueryRM addStuCouRec(String courseID, String studentID) {
		return stuCouScoList.addStuOfCou(courseID, studentID);
	}

	@Override
	public CourseQueryRM updateStuCouScoRec(String courseID, String studentID,
			int score) {
		return stuCouScoList.updateStuScoOfCou(courseID, studentID, score);
	}

	@Override
	public CourseQueryRM deleteCouOfTea(String courseID, String teacherID) {
		return teaCouList.deleteCouOfTea(courseID, teacherID);
	}

	@Override
	public CourseQueryRM addCouOfTea(String courseID, String teacherID) {
		return teaCouList.addCouOfTea(courseID, teacherID);
	}

	@Override
	public List<CourseVO> getAllCouOfSubModel(String collegeID, String modelID,
			String subModelID){
		return smcList.getAllCouOfSubModel(collegeID, modelID, subModelID);
	}
	
	public static void main(String[] args){
		try {
			RMIClient rmi = new RMIClient();
			CourseQueryLogicsvController c = new CourseQueryLogicsvController(rmi);
			List<CourseVO> l = c.getAllCouOfTea("001132002");
			for(CourseVO course : l){
				System.out.println(course.getCourseID());
			}
		} catch (NetConnectException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
